<template>

<div>
  <el-row>
    <mu-appbar title="线上充值" style="background-color:#409EFF">
      <mu-icon-button  icon="arrow_back_ios" slot="left" :to="{name: 'ContributeMenu' }"/>
    </mu-appbar>
  </el-row>

  <!-- <el-row>
    <el-col :span="12">
    </el-col>
    <el-col :span="12">
      <i class="el-icon-arrow-down" style="float:right" @click="handleTools"></i>
    </el-col>
  </el-row> -->

  <!-- <div class= "tools" v-show="tools">
    <el-row>
      <el-col :xs="6" :sm="4" :md="3" :lg="3">
        玩家账号
      </el-col>
      <el-col :xs="18" :sm="20" :md="21" :lg="21">
        <el-input v-model="condition.uid" size="mini" @blur="getRecharge"></el-input>
      </el-col>
    </el-row>
    <el-row>
      <el-col :xs="6" :sm="4" :md="3" :lg="3">
        起始日期
      </el-col>
      <el-col :xs="18" :sm="20" :md="21" :lg="21">
        <el-date-picker
          v-model="condition.startDay"
          type="date"
          placeholder="选择起始日期"
          size="mini"
          @change="getRecharge"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-col>
    </el-row>

    <el-row>
      <el-col :xs="6" :sm="4" :md="3" :lg="3">
        结束日期
      </el-col>
      <el-col :xs="18" :sm="20" :md="21" :lg="21">
        <el-date-picker
          v-model="condition.endDay"
          type="date"
          placeholder="选择结束日期"
          size="mini"
          @change="getRecharge"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-col>
    </el-row>

  </div> -->

  <el-row>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="totalNdotCreditOneDay"
        label="累计充值">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="日期">
      </el-table-column>
    </el-table>
  </el-row>

  <el-row>
    <center>
      <el-pagination
        small
        layout="prev, pager, next"
        :total="condition.total"
        :page-size="condition.pageSize"
        :current-page="condition.currentPage"
        @current-change="handleCurrentChange">
      </el-pagination>
    </center>
  </el-row>

</div>

</template>

<style scoped>
  .el-row {
    margin-bottom: 16px;
  }
  .el-col {
    margin-bottom: 8px;
  }
</style>

<script>
  export default {
    data () {
      return {
        tools: true,
        tableData: [],
        condition: {
          uid: '',
          startDay: this.$time.getDateBefore(new Date(), -3),
          endDay: this.$time.getDateBefore(new Date(), 0),
          currentPage: 1,
          pageSize: 10,
          total: 0,
          account: sessionStorage.getItem('account')
        },
        isAgent: false
      }
    },
    methods: {
      init () {
        this.getRecharge()
      },
      getRecharge () {
        if (this.condition.uid === '' || this.condition.uid.length === 0) {
          this.condition.uid = -1
        }
        let that = this
        this.$axios({
          method: 'get',
          url: '/api/CarrieroperatorService.getEveryDayRecharge',
          params: this.condition
        })
        .then(function (resp) {
          that.condition.uid = ''
          if (resp.data.status === 'success') {
            that.tableData = resp.data.data
            that.condition.total = resp.data.page.total
          } else {
            that.$message({
              showClose: true,
              message: resp.data.cause,
              type: 'warning'
            })
          }
        })
      },
      handleCurrentChange (val) {
        this.condition.currentPage = val
        this.getRecharge()
      },
      handleTools () {
        if (this.tools) {
          this.tools = false
        } else {
          this.tools = true
        }
      }
    },
    mounted () {
      if (sessionStorage.getItem('role') === 'agent') {
        this.isAgent = true
      }
      this.init()
    }
  }
</script>
